package mock.servicesdirectory.organisations.web.action;

import java.util.ArrayList;
import java.util.List;

import mock.servicesdirectory.organisations.business.businessimpl.OrganisationBOImpl;
import mock.servicesdirectory.organisations.business.businessinterface.OrganisationBO;
import mock.servicesdirectory.common.entities.Organisation;
import com.opensymphony.xwork2.ActionSupport;

public class OrganisationListAction extends ActionSupport {
	
	private OrganisationBO organisationBO;
	private List<Organisation> gridModel;	
	private Integer rows = 0;	
	private Integer page = 0;	
	private String sord;	
	private String sidx;
	private String searchField;
	private String searchString;
	private String searchOper;	
	private Integer total = 0;
	private Integer records = 0;
	private String mode;
	
	
	public String getMode() {
		return mode;
	}

	public void setMode(String mode) {
		this.mode = mode;
	}

	public OrganisationBO getOrganisationBO() {
		return organisationBO;
	}

	public void setOrganisationBO(OrganisationBO organisationBO) {
		this.organisationBO = organisationBO;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public String getSearchOper() {
		return searchOper;
	}

	public void setSearchOper(String searchOper) {
		this.searchOper = searchOper;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public String getSearchField() {
		return searchField;
	}

	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}

	public String getSidx() {
		return sidx;
	}

	public void setSidx(String sidx) {
		this.sidx = sidx;
	}

	public String getSord() {
		return sord;
	}

	public void setSord(String sord) {
		this.sord = sord;
	}

	public List<Organisation> getGridModel() {
		return gridModel;
	}

	public void setGridModel(List<Organisation> gridModel) {
		this.gridModel = gridModel;
	}

	public String execute() {		
		records = 30;
		rows = 10;
		
		setGridModel(organisationBO.getOrganisation());
		setTotal((int) Math.ceil((double) records / (double) rows));

		return SUCCESS;
	}

	//public String getJSON() {
	//	return execute();
	//}
	
	public String listOrganisation(){
		return SUCCESS;
	}
	// after Event click button, page detail will be showed
	public String creat(){
		// Redirect to page creat new Organisation
		mode = "Creat";
		return SUCCESS;
	}
	
	// Method to filter all Organisation
	public String includeInActive(){
		// Call methods to get all database of Organisation via OrganisationBOImpl.getOrganisation()
		return SUCCESS;
	}
	
	// Event double click in a row to amends 
	public String amend(){
		// Redirect page OrganisationDetail.jsp with tabs 4 5 6 will be showed
		mode="Amend";
		return SUCCESS;
	}
	
	// Method to filter all organisation
	public String filterAll(){
		// Call methods to get all database of Organisation via OrganisationBOImpl.getOrganisation()
		return SUCCESS;
	}
	
	// Method to filter Organisation start with 0-9
	public String filter09(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation(1)
		return SUCCESS;
	}
	
	// Method to filter Organisation start with ABCDE
	public String filterAE(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation(2)
		
		return SUCCESS;
	}
	
	// Method to filter Organisation start with FGHIJ
	public String filterFJ(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation(3)
		
		return SUCCESS;
	}
	
	// Method to filter Organisation start with KLMN
	public String filterKN(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation(4)
		
		return SUCCESS;
	}
	
	// Method to filter Organisation start with OPQR
	public String filterOR(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation(5)
		
		return SUCCESS;
		
	}
	
	// Method to filter Organisation start with STUV
	public String filterSV(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation(6)
		
		return SUCCESS;
	}
	
	// Method to filter Organisation start with STUV
	public String filterWZ(){
		// Call methos to get database of Organisation where name start with a digit 0-9 via OrganisationBOImpl.getOrganisation()
		
		return SUCCESS;
	}
}
